/*
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.bentley.kotlindemo.ui.kits.toptab

import android.app.Activity
import android.view.View
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.PagerAdapter
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.bentley.kotlindemo.ui.kits.bottomtab.fragments.MovieFragment
import com.bentley.kotlindemo.ui.kits.bottomtab.fragments.MusicFragment


const val MY_GARDEN_PAGE_INDEX = 0
const val PLANT_LIST_PAGE_INDEX = 1

class SunflowerPagerAdapterForActivity() : PagerAdapter() {

    /**
     * Mapping of the ViewPager page indexes to their respective Fragments
     */
    private val tabFragmentsCreators: Map<Int, () -> Fragment> = mapOf(
        MY_GARDEN_PAGE_INDEX to { MovieFragment() },
        PLANT_LIST_PAGE_INDEX to { MusicFragment() }
    )

//    override fun getItemCount() = tabFragmentsCreators.size
//
//    override fun createFragment(position: Int): Fragment {
//        return tabFragmentsCreators[position]?.invoke() ?: throw IndexOutOfBoundsException()
//    }

    override fun getCount(): Int {
        TODO("Not yet implemented")
    }

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view == `object`;
    }
}
